<?php
include_once "../lib/DAL/DmHeDaoTao.php";
class DmHeDaoTaoBLL{

public function __contruct(){
}

public function __destruct(){
}

public function getListHeDaoTao(){
    $sql = "select * from dm_hedaotao";
    $result = mysql_query($sql) or die(mysql_error());
    $arr_hdt = array();
    while($row = mysql_fetch_array($result)){
        $arr_hdt[] = $this->setHeDaoTaoBLL($row);
    }
    return $arr_hdt;
}
public function getItemHeDaoTao($madm_hdt){
    $sql = "select * from dm_hedaotao where madm_hdt='".$madm_hdt."'";
    $ex = mysql_query($sql);
    if (mysql_num_rows($ex)){
        $kq =mysql_fetch_array($ex);
        }
    return $kq;
}
public function insertHeDaoTao($hdt){
    $sql ="INSERT INTO dm_hedaotao(
        madm_hdt
        ,ten_hedt
        ,ten_vt_hedt
    ) VALUES (
        '".$hdt->getmadm_hdt()."'
        ,'".$hdt->getten_hedt()."'
        ,'".$hdt->getten_vt_hedt()."'
    )";
    $result = mysql_query($sql) or die (mysql_error());
   return $result;
}
public function updateHeDaoTao($madm_hdt,$ten_hedt,$ten_vt_hedt){
    $sql="UPDATE dm_hedaotao
        SET
        ten_hedt = '".$ten_hedt."' 
        ,ten_vt_hedt = '".$ten_vt_hedt."'
        WHERE madm_hdt ='".$madm_hdt."'";
    $result = mysql_query($sql) or die (mysql_error());
   return $result;
}
public function deleteHeDaoTao($madm_hdt){
    $sql="DELETE FROM dm_hedaotao WHERE madm_hdt = '".$madm_hdt."'";
    $result = mysql_query($sql) or die (mysql_error());
    return $result;
}
public function deleteAll(){
    $sql="DELETE FROM dm_hedaotao";
    $result = mysql_query($sql) or die (mysql_error());
    return $result;
}
public function setHeDaoTaoBLL($row){
    $dmHeDaoTao = new DmHeDaoTaoDAL();
    $dmHeDaoTao->setDmHeDaoTaoDAL($row['madm_hdt'],$row['ten_hedt'],$row['ten_vt_hedt']);
    return $dmHeDaoTao;
    }
 }
?>